//
//  SureView.m
//  YSSmartHome
//
//  Created by yanghao on 16/9/12.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import "SureView.h"
#import "YHMarcros.h"

@interface SureView ()
@property (nonatomic, strong)UIButton *sureBtn;
@end
@implementation SureView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.backgroundColor = kBgColor;
    [self addSubview:self.sureBtn];
    [self.sureBtn makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.height.equalTo(kIphoneSize_Height(47));
        make.leading.equalTo(self).offset(kIphoneSize_Widith(30));
        make.trailing.equalTo(self).offset(kIphoneSize_Widith(-30));
    }];
}

- (void)setBackColor:(UIColor *)backColor
{
    _backColor = backColor;
    self.backColor = backColor;
}
- (void)setTitle:(NSString *)title
{
    [self.sureBtn setTitle:title forState:UIControlStateNormal];
}

- (void)setStrImage:(NSString *)strImage
{
    [self.sureBtn setImage:[UIImage imageNamed:strImage] forState:UIControlStateNormal];
}
#pragma mark - event response

- (void)didTappedSureButton
{
    if (self.sureBtnClickBlock) {
        self.sureBtnClickBlock();
    }
}
#pragma mark - getters and setters

- (UIButton *)sureBtn
{
    if (!_sureBtn) {
        _sureBtn = [[UIButton alloc]init];
        [_sureBtn setTitle:@"确定" forState:UIControlStateNormal];
        [_sureBtn setBackgroundImage:[UIImage imageNamed:@"scene_circular_bg" ]forState:UIControlStateNormal];
        [_sureBtn addTarget:self action:@selector(didTappedSureButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return _sureBtn;
}
@end
